<template>
    <view>
        <view class="wallet-message-head">
            <van-nav-bar :title="state.titleName" left-arrow @click-left="onClickLeft" />
        </view>
        <view class="wallet-message-list">
            <view class="wallet-message-item" v-for="(item,index) in state.listData" :key="index">
                <WalletItem v-if="state.types == 1" :dataItem="item"/>
                <SettingItem v-else :dataItem="item"/>
            </view>
        </view>
    </view>
</template>
    
<script setup>
import { reactive, getCurrentInstance, onMounted } from "vue"
import { getAuthorization, setAuthorization } from "@/utils/auth.js"
import WalletItem from './walletItem.vue'
import SettingItem from './settingItem.vue'

import { onLoad } from '@dcloudio/uni-app'

const state = reactive({
    show: false,
    titleName:'钱包消息',
    types:1,
    listData:[]
})

const onClickLeft = () => history.back();

import { useAccountStore } from "@/store/index.js"

onLoad((options) => {
    state.titleName = options.types == 1 ? '钱包消息' : '私圈助手'
    state.types = options.types
    let store = useAccountStore()
    if(options.types == 1){
        let res = store.$state.chatListAll.filter(o => (o.chatType == 1 && o.from == 100169))
        res.forEach(o => {
            if(typeof o.content == 'string'){
                o.content = JSON.parse(o.content)
            }
        });
        state.listData = res
    }
    if(options.types == 2){
        let res = store.$state.chatListAll.filter(o => (o.chatType == 1 && o.from == 100170))
        res.forEach(o => {
            if(typeof o.content == 'string'){
                o.content = JSON.parse(o.content)
            }
        });
        state.listData = res
    }
    if(options.types == 3){
        let res = store.$state.chatListAll.filter(o => (o.chatType == 1 && o.from == 100171))
        rres.forEach(o => {
            if(typeof o.content == 'string'){
                o.content = JSON.parse(o.content)
            }
        });
        state.listData = res
    }
})



</script>
    
<style lang="scss" scoped>
.label-list {
    font-size: 28rpx;
    color: #ccc;

    text {
        margin-left: 10rpx;
    }

}

.wallet-message-list {
    min-height: calc(100vh - 150rpx);
    padding: 100rpx 0 50rpx 0;
    background-color: #F7F8F9;
}

.wallet-message-head {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
}

</style>
    